Skip to content

Tools: Test: Audio: Add double quotes to shell scripts - #2606

Merged
lgirdwood merged 1 commit into
thesofproject:masterfrom
singalsu:tools_fix_shell_scripts
Mar 26, 2020
Merged

lgirdwood merged 1 commit into
thesofproject:masterfrom
singalsu:tools_fix_shell_scripts

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

This patch adds the double quotes to shell scripts to avoid fails
with arguments or shell variables when there are space characters.

Signed-off-by: Seppo Ingalsuo seppo.ingalsuo@linux.intel.com

@singalsu
singalsu requested review from lgirdwood and marc-hb March 23, 2020 10:26
@singalsu
singalsu requested a review from jajanusz as a code owner March 23, 2020 10:26
Comment thread tools/test/audio/asrc_run.sh Resolved
Comment thread tools/test/audio/comp_run.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean "${FN_IN:-4}" ? If not add a comment explaining why the space is not a typo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch. I wonder it has not failed -- I need to check what happens.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the space needs to be there, it doesn't work with the space removed. It can be also "${FN_IN:(-4)}". I think it's better that way since it works with () with or without space before -4.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about negative offsets, sorry. I should have spent more time on https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

(I also didn't realize offsets were a bashism
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 - I digress)

I'm actually less comfortable with the (-4) than with the space because while confusing the space is documented extensively in the bash manual above but I couldn't find any sign that (-4) is officially supposed to work. Did you? The manual does mention that the offset can be an "arithmetic expression", so could you try ((-4)) if you like it? Otherwise back to the space with a comment to warn the casual reader that it is an offset and not a default value 4 with a typo.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll revert to -4 with space. I saw it in Stack Overflow so it was not proper documentation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but still no comment this is not a typo :-) Never mind, not worth holding the rest back.

Comment thread tools/test/audio/eqfir_run.sh Resolved
Comment thread tools/test/audio/eqfir_run.sh Resolved
Comment thread tools/test/audio/eqiir_run.sh Resolved
@lgirdwood

Copy link
Copy Markdown
Member

@marc-hb can you send a PR to add yourself as a codeowner for scripts.

@marc-hb

marc-hb commented Mar 24, 2020

Copy link
Copy Markdown
Collaborator

@marc-hb can you send a PR to add yourself as a codeowner for scripts.

OK, but let's cleanup bogus patterns first: PR #2621 .

@jajanusz

Copy link
Copy Markdown
Contributor

Reran tests, cos there was weird random error that it couldn't find cmocka.h (???), lets see if it helps

@singalsu

Copy link
Copy Markdown
Collaborator Author

Don't merge yet. I'm doing all recommendations by @marc-hb . I'm trying to improve my scripting style even if these are very small scripts.

@singalsu
singalsu force-pushed the tools_fix_shell_scripts branch from a6185a5 to 61a47fc Compare March 25, 2020 13:04
@singalsu
singalsu requested a review from marc-hb March 25, 2020 13:05
@singalsu

Copy link
Copy Markdown
Collaborator Author

I just pushed new version with all the fixes. The scripts work and are OK but the testbench has stopped to work again. I'll fix it in another PR.

Maybe testbench run step is still missing from CI since it fails to execute rather often.

@singalsu

Copy link
Copy Markdown
Collaborator Author

I was able to fix testbench and made a new PR. Something left not initialized in testbench resulted to crash with updated pipeline code.

@jajanusz

Copy link
Copy Markdown
Contributor

Maybe testbench run step is still missing from CI since it fails to execute rather often.

Internal CI does not run testbench (only builds it), so it shouldn't be an issue.

@singalsu

Copy link
Copy Markdown
Collaborator Author

Maybe testbench run step is still missing from CI since it fails to execute rather often.

Internal CI does not run testbench (only builds it), so it shouldn't be an issue.

It would be nice if CI could run e.g. 1s worth of sine wave with with one of these run scripts, e.g. volume_run.sh that's a very simple component. If output file is empty or much shorter than input it means testbench is broken.

The execute fail would not need to be a blocker for PR merge but some kind of orange warning and the developer who sees it could contact me. It would help me to faster fix / add things for what the fail is about. Testbench is being used ATM by external processing component developers so it would be nice if we can keep it in usable shape.

Comment thread tools/test/audio/asrc_run.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

if [ $# -gt 6 ]; then

So you can support a blank $6 argument, which you probably don't want to so forget it :-)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you meant

if [ $# -ne 6 ]; then
No problem, it's good to do once properly and learn good habits.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [ $# -ne 6 ]; then

Yes, thanks for knowing better :-)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread tools/test/audio/comp_run.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about negative offsets, sorry. I should have spent more time on https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

(I also didn't realize offsets were a bashism
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 - I digress)

I'm actually less comfortable with the (-4) than with the space because while confusing the space is documented extensively in the bash manual above but I couldn't find any sign that (-4) is officially supposed to work. Did you? The manual does mention that the offset can be an "arithmetic expression", so could you try ((-4)) if you like it? Otherwise back to the space with a comment to warn the casual reader that it is an offset and not a default value 4 with a typo.

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our current checkpatch version has a very "interesting" bug. If the SPDX is on line 3 you get this

WARNING: Misplaced SPDX-License-Identifier tag - use line 2 instead

... because the shebang obviously needs line 1. But when on line 2 you get this:

WARNING: Misplaced SPDX-License-Identifier tag - use line 1 instead

Maybe it suggests line 0 when on line 1 :-)

@jajanusz

Copy link
Copy Markdown
Contributor

Our current checkpatch version has a very "interesting" bug. If the SPDX is on line 3 you get this

It's taken from kernel 3-6 months ago, idk maybe there were som bug.

@jajanusz

Copy link
Copy Markdown
Contributor

Maybe testbench run step is still missing from CI since it fails to execute rather often.

Internal CI does not run testbench (only builds it), so it shouldn't be an issue.

It would be nice if CI could run e.g. 1s worth of sine wave with with one of these run scripts, e.g. volume_run.sh that's a very simple component. If output file is empty or much shorter than input it means testbench is broken.

The execute fail would not need to be a blocker for PR merge but some kind of orange warning and the developer who sees it could contact me. It would help me to faster fix / add things for what the fail is about. Testbench is being used ATM by external processing component developers so it would be nice if we can keep it in usable shape.

Internal CI is not for testing tools (it just uses logger, but there is no test for it). Jenkins is for that AFAIK.
@lgirdwood @xiulipan What do you think about it?

@lgirdwood

Copy link
Copy Markdown
Member

@jajanusz Yeah, I'm happy for Jenkins to also test the tooling. It does need done. @wenqingfu fyi, something to add to your CI list.

This patch adds the double quotes to shell scripts to avoid fails
with arguments or shell variables when there are space characters.

The processing components run scripts are all edited for better
structure with functions usage() and main() and with local variables
within functions.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu
singalsu force-pushed the tools_fix_shell_scripts branch from 61a47fc to ec0720e Compare March 25, 2020 18:16
@singalsu
singalsu requested a review from marc-hb March 25, 2020 18:19
Comment thread tools/test/audio/comp_run.sh Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but still no comment this is not a typo :-) Never mind, not worth holding the rest back.

@lgirdwood

Copy link
Copy Markdown
Member

Jenkins CI known issues.

@lgirdwood
lgirdwood merged commit 3ce54df into thesofproject:master Mar 26, 2020
marc-hb added a commit to marc-hb/sof that referenced this pull request Apr 4, 2020
Adding myself per Liam's instruction in PR thesofproject#2606

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
lgirdwood pushed a commit that referenced this pull request Apr 4, 2020
Adding myself per Liam's instruction in PR #2606

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@singalsu
singalsu deleted the tools_fix_shell_scripts branch September 15, 2022 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants